package com.enzoism.controller;

import com.enzoism.config.CodeMsg;
import com.enzoism.config.Result;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created with IntelliJ IDEA.
 * User: enzoism
 * Mark: API直接返回对象数据，使用RestController+@RequestMapping即可
 * Date: 2019/8/18- 17:43
 */
@RestController
@RequestMapping("/api")
public class ApiController {

    @RequestMapping("index.html")
    // 所有的API接口都应该用Result作为返回，当前仅仅作为演示而已
    public String index(){
        return "index";
    }

    @RequestMapping("success")
    public Result success(){
        return Result.success("operation success!");
    }

    @RequestMapping("error")
    public Result error(){
        return Result.error(CodeMsg.SERVER_ERROR);
    }
}
